package com.quarters.serviceImpl;

import com.quarters.bean.Quarters;
import com.quarters.bean.UserInfo;
import com.quarters.bean.layuiBean.ResultPage;
import com.quarters.bean.layuiBean.VoPage;
import com.quarters.bean.ztree.ZtreeBean;
import com.quarters.mapper.QuartersMapper;
import com.quarters.service.QuartersService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 小区表 服务实现类
 * </p>
 *
 * @author 冯政尚
 * @since 2019-09-02
 */
@Service
public class QuartersServiceImpl extends ServiceImpl<QuartersMapper, Quarters> implements QuartersService {

    /**
     * @param voPage
     * @return 后台查询
     */
    @Override
    public ResultPage<Quarters> selectMyPage(VoPage voPage,String quartersName) {
        Map<String, Object> paramMap = new HashMap<String, Object>();
        paramMap.put("page", (voPage.getPage() - 1) * voPage.getLimit());
        paramMap.put("limit", voPage.getLimit());
        paramMap.put("quartersName", quartersName);
        List<Quarters> list = baseMapper.selectMyPage(paramMap);
        Integer count = baseMapper.countMyPage(paramMap);
        ResultPage<Quarters> resultPage = new ResultPage<>();
        resultPage.setCode(0);
        resultPage.setCount(count);
        resultPage.setMsg("成功");
        resultPage.setData(list);
        return resultPage;
    }

    /**
     * @param userId
     * @return 根据对应的角色查询对应的小区
     */
    @Override
    public List<ZtreeBean> llist(Long userId) {
        return baseMapper.llist(userId);
    }

    @Override
    public List<ZtreeBean> allQuarters( ) {
        return baseMapper.allQuarters( );
    }

}
